﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using DTT.Core.Library;

public partial class Admin_Control_MenuLeft : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //
    }
    protected void repMenu_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        DataRowView item = (DataRowView)e.Item.DataItem;
        Literal ltrMenu = (Literal)e.Item.FindControl("ltrMenu");
        Repeater repMenuChild = (Repeater)e.Item.FindControl("repMenuChild");

        string iconMenu = "icon-list-ul";
        try
        {
            switch (item["MenuCode"].ToString().ToLower())
            {
                case "member":
                    iconMenu = "icon-group";
                    break;
                case "role":
                    iconMenu = "icon-cogs";
                    break;
                default:
                    break;
            }
        }
        catch { }
        string menuActive = "";
        menuActive = null;// AuMenuManager.CreateInstant().zGeParentCodebyUrl(menuactive.Value.ToString());
        if (item["MenuCode"].ToString()==menuActive)
        {
            ltrMenu.Text = @"<li class='has-sub active'>";
        }
        else
        {
            ltrMenu.Text = @"<li class='has-sub'>";
        }
        ltrMenu.Text =ltrMenu.Text+ @"<a href='javascript:;' class=''><span class='icon-box icon-menu'><i class='" + iconMenu + @"'></i></span>" + item["MenuName"].ToString() + @" <span class='arrow'></span></a>";
        DataTable menu = null;// AuMenuManager.CreateInstant().zGetMenubyParentCode(item["MenuCode"].ToString());
        if (menu != null && menu.Rows.Count > 0)
        {
            repMenuChild.DataSource = menu;
            repMenuChild.DataBind();
        }
    }
    protected void repMenuChild_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        DataRowView item = (DataRowView)e.Item.DataItem;
        Literal ltrMenuChild = (Literal)e.Item.FindControl("ltrMenuChild");



        string menuActive = "";
        
        
        if (menuActive == item["Url"].ToString())
        {
            ltrMenuChild.Text = @"<li class='active'><a href='" + item["Url"].ToString() + @"'>" + item["MenuName"].ToString() + @"</a></li>";
        }
        else
        {
            ltrMenuChild.Text = @"<li><a class='' href='" + item["Url"].ToString() + @"'>" + item["MenuName"].ToString() + @"</a></li>";
        }
    }
}